package com.example.jdai.jdai.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.jdai.jdai.R;
import com.example.jdai.jdai.config.Config;
import com.example.jdai.jdai.util.DataAll;
import com.example.jdai.jdai.util.DataLnfo;

import butterknife.BindArray;
import butterknife.BindColor;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by hellopyj on 2017/1/12.
 */

public class MyTextTip extends LinearLayout {
    @BindView(R.id.tv_tip)
    TextView tvTip;
    @BindArray(R.array.text_check)
    String[] tip;
    @BindColor(R.color.sh_red)
    int red;
    @BindColor(R.color.blue_text)
    int blue;

    public MyTextTip(Context context) {
        super(context);
        init(context,null);
    }

    public MyTextTip(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context,attrs);
    }

    public MyTextTip(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context,attrs);
    }

    public MyTextTip(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context,attrs);
    }

    void init(Context context, AttributeSet attrs) {
        LayoutInflater.from(context).inflate(R.layout.mytexttip, this);
        ButterKnife.bind(this);

    }
    public void setZhuangtai(String in){
        int index=0;
        if(!"".equals(in))
            try {
                index=Integer.parseInt(in);
            }
            catch (RuntimeException e){
                if(Config.ISDEBUG)
                   Log.v("mt",e.toString());
                index=0;
            }

        if(index>tip.length)
            index=tip.length;
        tvTip.setText(tip[index]);
        switch (index){
            case 0:
                tvTip.setTextColor(red);
                break;
            case 3:
                tvTip.setTextColor(blue);
                break;
            case 2:
                tvTip.setTextColor(red);
                break;
            case 1:
                tvTip.setTextColor(blue);
                break;
        }
    }
}
